﻿using System.Linq;
using System.Security.Claims;
using System.Web;
using System.Web.Mvc;
using Inovout.Component;
using Inovout.Data.Service;
using Inovout.Membership.Security;
using Inovout.People.Domain;
using Inovout.People.Membership.Domain;
using Inovout.Security;
using Inovout.Web.Mvc;


namespace Inovout.Membership.Account.WebPage.Controllers
{
    public class MeController : BaseController
    {
        IRepositoryService<PersonMembership> personMembershipService;
        public MeController()
        {
            personMembershipService = ComponentRegistry.Resolve<IRepositoryService<PersonMembership>>();
        }
     
        public JsonResult Index()
        {
            var authentication = HttpContext.GetOwinContext().Authentication;
            var identity = authentication.User.Identity as ClaimsIdentity;

            return Json<IPerson>(personMembershipService.FindById(int.Parse(identity.Name)).Person);
        }


    }
}